<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/

//Route::get('/', function()
//{
//  return View::make('hello');
//});


Route::model('member', 'Member');
Route::model('staff', 'Staff');
Route::model('role', 'Role');

Route::model('order', 'Order');
Route::model('food', 'Food');
Route::model('menu', 'Menu');
Route::model('setting', 'Setting');
Route::model('carousel', 'Carousel');

Route::controller('test', 'TestController');

/**
 * 后台管理
 */

Route::group(array('prefix' => 'back_end', 'before' => 'back_auth'), function()
{

//    Route::get('menus/create', 'BackMenuController@doCreate');
//    Route::post('menus/create', 'BackMenuController@doCreate');
//    Route::get('menus/update/{menu}', 'BackMenuController@doUpdate');
//    Route::post('menus/update/{menu}', 'BackMenuController@doUpdate');
//    Route::get('menus/delete/{menu}', 'BackMenuController@doDelete');
//    Route::post('menus/delete/{menu}', 'BackMenuController@doDelete');
//    Route::controller('menus', 'BackMenuController');


    # Staff Management
    Route::get('staffs/create', 'BackStaffController@doCreate');
    Route::post('staffs/create', 'BackStaffController@doCreate');
    Route::get('staffs/view/{staff}', 'BackStaffController@doView');
    Route::get('staffs/update/{staff}', 'BackStaffController@doUpdate');
    Route::post('staffs/update/{staff}', 'BackStaffController@doUpdate');
    Route::get('staffs/delete/{staff}', 'BackStaffController@doDelete');
    Route::post('staffs/delete/{staff}', 'BackStaffController@doDelete');

    Route::get('staffs/modify_password/{staff}', 'BackStaffController@doModifyPassword');
    Route::post('staffs/modify_password/{staff}', 'BackStaffController@doModifyPassword');
    Route::controller('staffs', 'BackStaffController');

    # Member Management
    Route::get('members/create', 'BackMemberController@doCreate');
    Route::post('members/create', 'BackMemberController@doCreate');
    Route::get('members/view/{member}', 'BackMemberController@doView');
    Route::get('members/update/{member}', 'BackMemberController@doUpdate');
    Route::post('members/update/{member}', 'BackMemberController@doUpdate');
    Route::get('members/delete/{member}', 'BackMemberController@doDelete');
    Route::post('members/delete/{member}', 'BackMemberController@doDelete');

    Route::controller('members', 'BackMemberController');

    # Role Management
    Route::get('roles/create', 'BackRoleController@doCreate');
    Route::post('roles/create', 'BackRoleController@doCreate');
    Route::get('roles/view/{role}', 'BackRoleController@doView');
    Route::get('roles/update/{role}', 'BackRoleController@doUpdate');
    Route::post('roles/update/{role}', 'BackRoleController@doUpdate');
    Route::get('roles/delete/{role}', 'BackRoleController@doDelete');
    Route::post('roles/delete/{role}', 'BackRoleController@doDelete');
    Route::controller('roles', 'BackRoleController');


    # Food Management
    Route::get('foods/create', 'BackFoodController@doCreate');
    Route::post('foods/create', 'BackFoodController@doCreate');
    Route::get('foods/view/{food}', 'BackFoodController@doView');
    Route::get('foods/update/{food}', 'BackFoodController@doUpdate');
    Route::post('foods/update/{food}', 'BackFoodController@doUpdate');
    Route::get('foods/delete/{food}', 'BackFoodController@doDelete');
    Route::post('foods/delete/{food}', 'BackFoodController@doDelete');
    Route::post('foods/export', 'BackFoodController@doExport');
    Route::post('foods', 'BackFoodController@getIndex');
    Route::controller('foods', 'BackFoodController');

    # Menu Management
    Route::get('menus/create', 'BackMenuController@doCreate');
    Route::post('menus/create', 'BackMenuController@doCreate');
    Route::get('menus/view/{menu}', 'BackMenuController@doView');
    Route::get('menus/update/{menu}', 'BackMenuController@doUpdate');
    Route::post('menus/update/{menu}', 'BackMenuController@doUpdate');
    Route::get('menus/delete/{menu}', 'BackMenuController@doDelete');
    Route::post('menus/delete/{menu}', 'BackMenuController@doDelete');
    Route::post('menus/export', 'BackMenuController@doExport');
    Route::post('menus', 'BackMenuController@getIndex');
    Route::controller('menus', 'BackMenuController');

    # OrderManagement
    Route::get('orders/today_get_list', 'BackOrderController@getTodayGetList');
    Route::get('orders/today_send_list', 'BackOrderController@getTodaySendList');
    Route::get('orders/getDetail/{order}', 'BackOrderController@getDetail');
    Route::get('orders/ordershow', 'BackOrderController@doOrderShow');
    Route::get('orders/order_today_show', 'BackOrderController@getOrderToday');
    Route::get('orders/order_change', 'BackOrderController@changeStatus');
    Route::get('orders/delete_order_today', 'BackOrderController@deleteOrderToday');
    Route::post('orders', 'BackOrderController@getIndex');
    Route::controller('orders', 'BackOrderController');

    # Carousel Management
    Route::get('carousels/create', 'BackCarouselController@doCreate');
    Route::post('carousels/create', 'BackCarouselController@doCreate');
    Route::get('carousels/update/{carousel}', 'BackCarouselController@doUpdate');
    Route::post('carousels/update/{carousel}', 'BackCarouselController@doUpdate');
    Route::get('carousels/delete/{carousel}', 'BackCarouselController@doDelete');
    Route::post('carousels/delete/{carousel}', 'BackCarouselController@doDelete');
    Route::get('carousels/go_top/{carousel}', 'BackCarouselController@doGoTop');
    Route::post('carousels', 'BackCarouselController@getIndex');
    Route::controller('carousels', 'BackCarouselController');

    # SettingManagement
    Route::get('settings/update/{setting}', 'BackSettingController@doUpdate');
    Route::post('settings/update/{setting}', 'BackSettingController@doUpdate');

    Route::controller('/', 'BackDashboardController');

});

// 登录
Route::get('admin/login', 'BackIndexController@doLogin');
Route::post('admin/login', 'BackIndexController@doLogin');

Route::get('admin/logout', 'BackIndexController@doLogout');


//File Upload
Route::post('file/ck_upload', 'FileController@postCkUpload');
Route::get('file/image', 'FileController@getImageUpload');
Route::post('file/image', 'FileController@postImageUpload');
Route::delete('file/image', 'FileController@deleteImageUpload');


Route::get( 'file/thumbnail', 'FileController@getThumbnail');
Route::get( 'file/image', 'FileController@getImage');

Route::pattern('sx', '[0-9]+');
Route::pattern('sy', '[0-9]+');
Route::get( 'file/image_crop/{sx}/{sy}/{sw}', 'FileController@getImageCrop');


Route::post('ufiles/documentupload', 'FileController@postDocumentUpload');
Route::delete('ufiles/senddocumentupload', 'FileController@deleteSendDocumentUpload');


// Confide routes
//Route::get('users/create', 'UsersController@create');
//Route::post('users', 'UsersController@store');
//Route::get('user/login', 'UsersController@login');
//Route::post('users/login', 'UsersController@doLogin');
//Route::get('users/confirm/{code}', 'UsersController@confirm');
//Route::get('users/forgot_password', 'UsersController@forgotPassword');
//Route::post('users/forgot_password', 'UsersController@doForgotPassword');
//Route::get('users/reset_password/{token}', 'UsersController@resetPassword');
//Route::post('users/reset_password', 'UsersController@doResetPassword');
//Route::get('users/logout', 'UsersController@logout');




/**
 * 自助终端
 */

Route::group(array('prefix' => 'self_service_end'), function()
{
    Route::get('foods/detail/{food}', 'SelfFoodController@getDetail');
    Route::controller('/', 'SelfDashboardController');

});
Route::get('/','SelfDashboardController@getIndex');
// 图片轮播 首页推荐 菜品下单排行， 菜品销售排行
Route::get('self/carousel', 'SelfIndexController@doCarousel');
// 自助终端登录
Route::get('self/login', 'SelfIndexController@doLogin');
//创建订单
Route::get('self/add_order', 'SelfFoodController@doOrder');
//获取订单信息
Route::get('self/get_picket', 'SelfIndexController@getOrderPicket');
//设置订单为已结算
Route::get('self/set_picket_settled', 'SelfIndexController@setOrderSettled');
//设置订单为已出票
Route::get('self/set_picket_printed', 'SelfIndexController@setOrderPrinted');
//判断订单是否支付成功
Route::get('self/get_order_is_settled','SelfIndexController@getIsSettled');



/**
 * 手机端管理
 */

Route::group(array('prefix' => 'mobile_end', 'before' => 'mobile_auth'), function()
{
    # Food
    Route::get('foods/detail/{food}', 'MobileFoodController@getDetail');
    Route::get('foods/today', 'MobileFoodController@getTodayFoods');
    Route::controller('foods', 'MobileFoodController');

    # Member
//    Route::get('members/detail/{member}', 'MobileOrderController@getDetail');

    # 账户
    Route::get('accounts/index', 'MobileAccountController@getIndex');

    # 购物篮
    Route::get('baskets/index', 'MobileBasketController@getIndex');
    Route::post('baskets/add_food', 'MobileBasketController@addFood');
    Route::post('baskets/add_food_json', 'MobileBasketController@addFoodForJSON');
    Route::post('baskets/drop_food/{food}', 'MobileBasketController@dropFood');
    Route::post('baskets/drop_food_json', 'MobileBasketController@dropFoodForJSON');
    Route::post('baskets/update_food_count', 'MobileBasketController@updateFoodCount');

    # 订单
    Route::get('orders/index', 'MobileOrderController@getIndex');
    Route::get('orders/settle_by_integral/{order}', 'MobileOrderController@doSettleByIntegral');
    Route::get('orders/detail/{order}', 'MobileOrderController@getDetail');
    Route::post('orders/create', 'MobileOrderController@doCreate');
    Route::post('orders/delete/{order}', 'MobileOrderController@doDelete');
    Route::get('orders/get_qrcode/{order}', 'MobileOrderController@getORCode');

//    Route::controller('/(:token)/(:user)/(:auth)', 'MobileDashboardController');
    Route::controller('/', 'MobileDashboardController');
});

// 微信端登录
Route::get('mobile/login', 'MobileIndexController@doWeixinLogin');
Route::post('mobile/login', 'MobileIndexController@doWeixinLogin');
// App端登录
Route::get('mobile/web_login_action', 'MobileIndexController@doLoginAction');
Route::get('mobile/web_login', 'MobileIndexController@doLogin');
Route::post('mobile/web_login', 'MobileIndexController@doLogin');
Route::get('mobile/logout', 'MobileIndexController@doLogout');
// App注册
Route::get('mobile/app_register', 'MobileIndexController@doRegister');
Route::post('mobile/app_register', 'MobileIndexController@doRegister');
//支付 手机和自助终端
Route::get('mobile_ali_pay','AliPayController@MobilePay');
Route::get('machine_ali_pay','AliPayController@MachinePay');
//支付宝同步通知
Route::any('check_syn_pay_res/{type}','AliPayController@synPayResCheck');
//支付宝异步通知
Route::any('check_asy_pay_res','AliPayController@asyPayResCheck');
//微信支付
Route::get('machine_wx_pay','WxPayController@MachinePay');
//微信支付 异步通知
Route::any('mobile_wx_pay','WxPayController@asyPayResCheck');
